/*
 * R.java
 *
 * Created on 10 april 2008, 22:09
 */

package client.gui;

import client.communication.*;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.text.Format;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.logging.Level;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import org.apache.log4j.Logger;
import data.Gebruiker;

/**
 *
 * @author  Gunnar Verhulst
 */
public class Registreer extends javax.swing.JPanel {
    
    private Logger logger = Logger.getLogger(Registreer.class);
    private JFrame parent;
    private Gebruiker g = null;
    private ImageIcon img=null;
    private boolean isRegistratie=true;
    
    
    /** Creates new form R */
    public Registreer(String ip,int poort, JFrame frame) {
        initComponents();
        setParentFrame(frame);
        boolean gelukt = ClientCommunication.getInstance().makeConnection(ip, poort);
        g= new Gebruiker();
        g.setOnline(false);
        g.setGaming(false);
        g.setScoreId(0);
        if(!gelukt){
            //Venster sluiten als de connectie niet gelukt is
            parent.setEnabled(false);
        }else{
            maakLeeg();
        }
    }
    
    public Registreer(Gebruiker gebruiker, JFrame frame)
    {
        //this.g=g;
        initComponents();
        isRegistratie=false;
        vulin(gebruiker);
        g=gebruiker;
        setParentFrame(frame);
    }
    
    public Registreer(){
        initComponents();
        maakLeeg();
    }
    
    public void setParentFrame(JFrame parent){
        this.parent = parent;
    }
        
    public void maakLeeg(){
        if(isRegistratie)
            txtNaam.setText("");
        txtPaswoord.setText("");
        txtBevestigPaswoord.setText("");
        txtGeslacht.setText("");
        txtEmail.setText("");
        txtDatum.setText("");
        txtHobbies.setText("");
        txtExtra.setText("");
        txtAvatar.setText("");
        txtNaam.requestFocus();
    }
    public void vulin(Gebruiker gebruiker){
        
       

       
        txtNaam.setText(gebruiker.getNickname());
        txtNaam.setEditable(false);
        txtPaswoord.setText("");
        txtBevestigPaswoord.setText("");
        txtGeslacht.setText(gebruiker.getGeslacht());
        txtEmail.setText(gebruiker.getEmail());
         if (!gebruiker.getGeboortedatum().equals(null)) {
            Date d = gebruiker.getGeboortedatum();
            txtDatum.setText(d.toString().split(" ")[2] + "-" + d.toString().split(" ")[1] + "-" + d.toString().split(" ")[5]);
        }
         if (!gebruiker.getHobbys().equals(null)) {
            txtHobbies.setText(gebruiker.getHobbys());
        }
        if (!gebruiker.getExtra().equals(null)) {
            txtExtra.setText(gebruiker.getExtra());
        }
        txtAvatar.setText(gebruiker.getAvatar());
        txtNaam.requestFocus();
    }

    public void registreren(boolean bool) {
        logger.info("is een update: " + bool);
        logger.info("is een update scherm: "+ isRegistratie);
        if(bool && !isRegistratie){
           
                try {
                    //gebruiker updaten
                    logger.info("in update gebruiker");
                  //  g.setAvatar(txtAvatar.getText().equals("") ? "null" : "/Avatars/" + g.getNickname() + " - " + jfcAvatar.getSelectedFile().getName());
                   
                    ClientCommunication.getInstance().updateSpeler(g);
                    logger.info("update van gebruiker afgehandeld");
                    /*
                    if (!txtAvatar.getText().equals("")) {
                      //  img = createImageIcon(jfcAvatar.getSelectedFile());
                      //  ClientCommunication.getInstance().zendAvatarAanvraag(g.getNickname() + " - " + jfcAvatar.getSelectedFile().getName());
                      //  System.out.println((this.getParent()).getClass());
                        parent.dispose();
                    } else {
                        parent.dispose();
                    }
                     * */
                } catch (IOException ex) {
                    java.util.logging.Logger.getLogger(Registreer.class.getName()).log(Level.SEVERE, null, ex);
                } catch (ClassNotFoundException ex) {
                    java.util.logging.Logger.getLogger(Registreer.class.getName()).log(Level.SEVERE, null, ex);
                } 
               ((Chatroom)parent).Closerfrm();
        }
        else if (bool  && isRegistratie)
        {

                txtNaam.selectAll();
                txtNaam.requestFocus();
        }
        else if(!bool && isRegistratie)
        {
            g.setAvatar(txtAvatar.getText().equals("")?"null":"/Avatars/"+g.getNickname()+ " - " +jfcAvatar.getSelectedFile().getName());
            ClientCommunication.getInstance().RegistreerGebruiker(g);
            if(!txtAvatar.getText().equals("")){
                img = createImageIcon(jfcAvatar.getSelectedFile());
                ClientCommunication.getInstance().zendAvatarAanvraag(g.getNickname()+ " - " +jfcAvatar.getSelectedFile().getName());
                System.out.println((this.getParent()).getClass());
                parent.dispose();
            }else
                parent.dispose();
            
        }
    }

    public ImageIcon getImg() {
        return img;
    }

    private void verzendenGegevens() {
        // TODO add your handling code here:
        if (txtNaam.getText().equals("")) {
            txtNaam.requestFocus();
        } else if (!txtNaam.getText().equals("") && (txtNaam.getText().length() > 25 || !txtNaam.getText().matches("([a-zA-Z]|[0-9])+"))) {
            txtNaam.selectAll();
            txtNaam.requestFocus();
        } else if (txtPaswoord.getPassword().length > 12 || txtPaswoord.getPassword().length == 0 || !new String(txtPaswoord.getPassword()).matches("([a-zA-Z]|[0-9])+") || !Arrays.equals(txtPaswoord.getPassword(), txtBevestigPaswoord.getPassword()) || txtBevestigPaswoord.getPassword().length == 0) {
            txtPaswoord.selectAll();
            txtBevestigPaswoord.selectAll();
            txtPaswoord.requestFocus();
        } else if (txtEmail.getText().equals("")) {
            txtEmail.selectAll();
            txtEmail.requestFocus();
        } else if (!txtEmail.getText().equals("") && (txtEmail.getText().length() > 45 || !txtEmail.getText().matches("(\\w+.*)+@\\w+.\\w+"))) {
            txtEmail.selectAll();
            txtEmail.requestFocus();
        } else if (!txtGeslacht.getText().equals("") && !txtGeslacht.getText().matches("M|V|m|v")) {
            txtGeslacht.selectAll();
            txtGeslacht.requestFocus();
        } else if (!txtHobbies.getText().equals("") && (txtHobbies.getText().length() > 100 || !txtHobbies.getText().matches("(.)+"))) {
            txtHobbies.selectAll();
            txtHobbies.requestFocus();
        } else if (!txtExtra.getText().equals("") && (txtExtra.getText().length() > 50 || !txtExtra.getText().matches("(.)+"))) {
            txtExtra.selectAll();
            txtExtra.requestFocus();
        } else if (!txtAvatar.getText().equals("") && txtAvatar.getText().length() > 45) {
            txtAvatar.selectAll();
            txtAvatar.requestFocus();
        } else {
            try {
                //g = new Gebruiker();
                g.setNickname(txtNaam.getText());
                g.setPaswoord(new String(txtPaswoord.getPassword()));
                g.setEmail(txtEmail.getText());
                g.setGeslacht(txtGeslacht.getText().equals("") ? "M" : txtGeslacht.getText());
                g.setHobbys(txtHobbies.getText().equals("") ? "null" : txtHobbies.getText());
                g.setExtra(txtExtra.getText().equals("") ? "null" : txtExtra.getText());
                //g.setAvatar(txtAvatar.getText().equals("")?"null":txtExtra.getText());

                //System.out.println(txtPaswoord.getPassword());

                if (!txtDatum.getText().equals("")) {
                    Date date;
                    Format formatter;
                    formatter = new SimpleDateFormat("dd-MM-yyyy");
                    date = (Date) formatter.parseObject(txtDatum.getText());
                    g.setGeboortedatum(date);
                } else {
                    Date date = new Date();
                    g.setGeboortedatum(date);
                }



                ClientCommunication.getInstance().checkNicknameBestaatAl(g.getNickname());
                //
            } catch (ParseException ex) {
                System.out.println("Datum was fout");
                txtDatum.selectAll();
                txtDatum.requestFocus();
            }
        }
    }
    class jpgFilter extends javax.swing.filechooser.FileFilter {
            public boolean accept(File file) {
                if (file.isDirectory()) { return true; }
                String filename = file.getName();
                return filename.endsWith(".jpg");
            }
            public String getDescription() {
                return "*.jpg";
            }
        }
        class gifFilter extends javax.swing.filechooser.FileFilter {
            public boolean accept(File file) {
                if (file.isDirectory()) { return true; }
                String filename = file.getName();
                return filename.endsWith(".gif");
            }
            public String getDescription() {
                return "*.gif";
            }
        }
        class bmpFilter extends javax.swing.filechooser.FileFilter {
            public boolean accept(File file) {
                if (file.isDirectory()) { return true; }
                String filename = file.getName();
                return filename.endsWith(".bmp");
            }
            public String getDescription() {
                return "*.bmp";
            }
        }
        class pngFilter extends javax.swing.filechooser.FileFilter {
            public boolean accept(File file) {
                if (file.isDirectory()) { return true; }
                String filename = file.getName();
                return filename.endsWith(".png");
            }
            public String getDescription() {
                return "*.png";
            }
        }
        
        public ImageIcon createImageIcon(File f){
            ImageIcon imgi = null;
            try {
                BufferedImage img = ImageIO.read(f);
                Color c = new Color(img.getRGB(0, 0));
                imgi = new ImageIcon(img);
            } catch (IOException ex) {
                System.out.println("Fout bij createImageIcon"+ex);
            }
            return imgi;
        }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        lblNaam = new javax.swing.JLabel();
        lblPaswoord = new javax.swing.JLabel();
        lblBevestigPaswoord = new javax.swing.JLabel();
        lblGeslacht = new javax.swing.JLabel();
        lblDatum = new javax.swing.JLabel();
        lblEmail = new javax.swing.JLabel();
        lblHobbies = new javax.swing.JLabel();
        lblExtra = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        ButtonPanel = new javax.swing.JPanel();
        btnVerzenden = new javax.swing.JButton();
        btnLeegMaken = new javax.swing.JButton();
        helpLinkLabel1 = new client.gui.controls.HelpLinkLabel();
        txtNaam = new javax.swing.JTextField();
        lblOptioneel = new javax.swing.JLabel();
        txtPaswoord = new javax.swing.JPasswordField();
        txtBevestigPaswoord = new javax.swing.JPasswordField();
        txtGeslacht = new javax.swing.JTextField();
        txtDatum = new javax.swing.JTextField();
        txtEmail = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtHobbies = new javax.swing.JTextArea();
        lblAvatar = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        txtExtra = new javax.swing.JTextArea();
        lblOptioneel1 = new javax.swing.JLabel();
        lblOptioneel2 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        txtAvatar = new javax.swing.JTextField();
        jSeparator3 = new javax.swing.JSeparator();
        jSeparator4 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        btnBladeren = new javax.swing.JButton();
        jfcAvatar = new javax.swing.JFileChooser();
        lblOptioneel3 = new javax.swing.JLabel();

        jLabel1.setText("Velden aangeduid met een * zijn verplichte velden, deze zonder zijn optioneel");

        lblNaam.setText("Naam:");

        lblPaswoord.setText("Paswoord:");

        lblBevestigPaswoord.setText("Bevestig paswoord");

        lblGeslacht.setText("Geslacht:");

        lblDatum.setText("Geboortedatum:");

        lblEmail.setText("Email:");

        lblHobbies.setText("Hobbies:");

        lblExtra.setText("Extra:");

        btnVerzenden.setText("Verzenden");
        btnVerzenden.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Verzenden(evt);
            }
        });

        btnLeegMaken.setText("Leeg maken");
        btnLeegMaken.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLeegMakenActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout ButtonPanelLayout = new javax.swing.GroupLayout(ButtonPanel);
        ButtonPanel.setLayout(ButtonPanelLayout);
        ButtonPanelLayout.setHorizontalGroup(
            ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtonPanelLayout.createSequentialGroup()
                .addGap(208, 208, 208)
                .addComponent(helpLinkLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnLeegMaken)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnVerzenden)
                .addContainerGap())
        );
        ButtonPanelLayout.setVerticalGroup(
            ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtonPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnVerzenden)
                    .addComponent(btnLeegMaken)
                    .addComponent(helpLinkLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        lblOptioneel.setText("*");

        txtHobbies.setColumns(20);
        txtHobbies.setLineWrap(true);
        txtHobbies.setRows(5);
        txtHobbies.setAutoscrolls(false);
        jScrollPane1.setViewportView(txtHobbies);

        lblAvatar.setText("Avatar:");

        txtExtra.setColumns(20);
        txtExtra.setLineWrap(true);
        txtExtra.setRows(5);
        jScrollPane3.setViewportView(txtExtra);

        lblOptioneel1.setText("*");

        lblOptioneel2.setText("*");

        jLabel2.setText("Persoonlijke informatie:");
        jLabel2.setAlignmentX(0.5F);

        btnBladeren.setText("Bladeren");
        btnBladeren.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBladerenActionPerformed(evt);
            }
        });

        lblOptioneel3.setText("*");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 1, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblExtra, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                                    .addComponent(lblAvatar))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(txtAvatar, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(btnBladeren)
                                        .addGap(37, 37, 37))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE)
                                        .addGap(33, 33, 33))))
                            .addComponent(ButtonPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(lblGeslacht, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)
                                    .addComponent(lblDatum, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)
                                    .addComponent(lblHobbies, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 0, 0)
                                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(lblEmail, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)
                                    .addComponent(lblBevestigPaswoord, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)
                                    .addComponent(lblPaswoord, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)
                                    .addComponent(lblNaam, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(txtEmail, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txtBevestigPaswoord, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txtPaswoord, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txtNaam, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(lblOptioneel3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblOptioneel2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblOptioneel1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblOptioneel, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addComponent(txtGeslacht)
                                    .addComponent(txtDatum, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE)
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(34, 34, 34)))
                        .addGap(21, 21, 21))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtNaam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblOptioneel)
                                    .addComponent(lblNaam))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtPaswoord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblOptioneel1)
                                    .addComponent(lblPaswoord))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtBevestigPaswoord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblOptioneel2)
                                    .addComponent(lblBevestigPaswoord))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblEmail)
                                    .addComponent(lblOptioneel3))
                                .addGap(13, 13, 13)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(lblGeslacht)
                                    .addComponent(txtGeslacht, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(lblDatum)
                                    .addComponent(txtDatum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(8, 8, 8)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblHobbies)
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(146, 146, 146)
                        .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblExtra)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblAvatar)
                    .addComponent(txtAvatar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnBladeren))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ButtonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(32, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnLeegMakenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeegMakenActionPerformed
        // TODO add your handling code here:
        maakLeeg();
    }//GEN-LAST:event_btnLeegMakenActionPerformed

    private void Verzenden(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Verzenden
        verzendenGegevens();
        
    }//GEN-LAST:event_Verzenden

    private void btnBladerenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBladerenActionPerformed
        // TODO add your handling code here:
        jfcAvatar.addChoosableFileFilter(new bmpFilter());
        jfcAvatar.addChoosableFileFilter(new gifFilter());
        jfcAvatar.addChoosableFileFilter(new pngFilter());
        jfcAvatar.addChoosableFileFilter(new jpgFilter());
        jfcAvatar.showOpenDialog(this);
        if(!jfcAvatar.getSelectedFile().equals(null))
            txtAvatar.setText(jfcAvatar.getSelectedFile().getName());
           
    }//GEN-LAST:event_btnBladerenActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel ButtonPanel;
    private javax.swing.JButton btnBladeren;
    private javax.swing.JButton btnLeegMaken;
    private javax.swing.JButton btnVerzenden;
    private client.gui.controls.HelpLinkLabel helpLinkLabel1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JFileChooser jfcAvatar;
    private javax.swing.JLabel lblAvatar;
    private javax.swing.JLabel lblBevestigPaswoord;
    private javax.swing.JLabel lblDatum;
    private javax.swing.JLabel lblEmail;
    private javax.swing.JLabel lblExtra;
    private javax.swing.JLabel lblGeslacht;
    private javax.swing.JLabel lblHobbies;
    private javax.swing.JLabel lblNaam;
    private javax.swing.JLabel lblOptioneel;
    private javax.swing.JLabel lblOptioneel1;
    private javax.swing.JLabel lblOptioneel2;
    private javax.swing.JLabel lblOptioneel3;
    private javax.swing.JLabel lblPaswoord;
    private javax.swing.JTextField txtAvatar;
    private javax.swing.JPasswordField txtBevestigPaswoord;
    private javax.swing.JTextField txtDatum;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextArea txtExtra;
    private javax.swing.JTextField txtGeslacht;
    private javax.swing.JTextArea txtHobbies;
    private javax.swing.JTextField txtNaam;
    private javax.swing.JPasswordField txtPaswoord;
    // End of variables declaration//GEN-END:variables

}
